package com.ruoyi.sessions.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sessions.domain.SessionTracks;
import com.ruoyi.sessions.service.ISessionTracksService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会话-歌曲Controller
 * 
 * @author lin
 * @date 2025-03-04
 */
@RestController
@RequestMapping("/sessions/sTracks")
public class SessionTracksController extends BaseController
{
    @Autowired
    private ISessionTracksService sessionTracksService;

    /**
     * 查询会话-歌曲列表
     */
    @PreAuthorize("@ss.hasPermi('sessions:sTracks:list')")
    @GetMapping("/list")
    public TableDataInfo list(SessionTracks sessionTracks)
    {
        startPage();
        List<SessionTracks> list = sessionTracksService.selectSessionTracksList(sessionTracks);
        return getDataTable(list);
    }

    /**
     * 导出会话-歌曲列表
     */
    @PreAuthorize("@ss.hasPermi('sessions:sTracks:export')")
    @Log(title = "会话-歌曲", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SessionTracks sessionTracks)
    {
        List<SessionTracks> list = sessionTracksService.selectSessionTracksList(sessionTracks);
        ExcelUtil<SessionTracks> util = new ExcelUtil<SessionTracks>(SessionTracks.class);
        util.exportExcel(response, list, "会话-歌曲数据");
    }

    /**
     * 获取会话-歌曲详细信息
     */
    @PreAuthorize("@ss.hasPermi('sessions:sTracks:query')")
    @GetMapping(value = "/{sessionId}")
    public AjaxResult getInfo(@PathVariable("sessionId") Long sessionId)
    {
        return success(sessionTracksService.selectSessionTracksBySessionId(sessionId));
    }

    /**
     * 新增会话-歌曲
     */
    @PreAuthorize("@ss.hasPermi('sessions:sTracks:add')")
    @Log(title = "会话-歌曲", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SessionTracks sessionTracks)
    {
        return toAjax(sessionTracksService.insertSessionTracks(sessionTracks));
    }

    /**
     * 修改会话-歌曲
     */
    @PreAuthorize("@ss.hasPermi('sessions:sTracks:edit')")
    @Log(title = "会话-歌曲", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SessionTracks sessionTracks)
    {
        return toAjax(sessionTracksService.updateSessionTracks(sessionTracks));
    }

    /**
     * 删除会话-歌曲
     */
    @PreAuthorize("@ss.hasPermi('sessions:sTracks:remove')")
    @Log(title = "会话-歌曲", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sessionIds}")
    public AjaxResult remove(@PathVariable Long[] sessionIds)
    {
        return toAjax(sessionTracksService.deleteSessionTracksBySessionIds(sessionIds));
    }
}
